package com.title6;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.TreeSet;

/**
 * @Author milian
 * @Date 2021/8/2 0002 21:05
 */
public class title6 {
    public static void main(String[] args) throws IOException {
        Student s1 = new Student("李四", 21, 98);
        Student s2 =new Student("张三", 18, 88);
        Student s3 = new Student("老王", 24, 91);
        TreeSet<Student> studentTreeSet = new TreeSet<>();
        studentTreeSet.add(s1);
        studentTreeSet.add(s2);
        studentTreeSet.add(s3);
        FileOutputStream fos = new FileOutputStream("homeWork\\stu.txt");
        for (Student student : studentTreeSet) {
            fos.write((student.getName()+","+student.getAge()+","+student.getScore()+"\r\n").getBytes());
        }
        fos.close();

    }
}
